<template>
    <el-radio-group v-model="status">
      <template  v-if="isButton">
      <el-radio-button
                       v-for="(dict,index) in statusOptions"
                       :key="index"
                       :label="dict.value"
      >{{dict.name}}</el-radio-button></template>
      <template  v-else>
      <el-radio
        v-for="(dict,index) in statusOptions"
        :key="index"
        :label="dict.value"
      >{{dict.name}}</el-radio></template>
    </el-radio-group>
</template>
<script>
  export default {
    name:"DictRadio",
    props:{
      value:{
        type:[Number,String,Boolean],
        default:undefined
      },
      distKey:{
        type:String,
        default:""
      },
      isButton:{
        type:Boolean,
        default:false
      }
    },
    data(){
      return{
        statusOptions:[],
      }
    },
    created() {
      this.getDicts(this.distKey).then(res => {
        this.statusOptions = res.data;
      });
    },
    computed:{
      status:{
        get(){
          return this.value
        },
        set(v){
          this.$emit("input",v)
        }
      }
    }
  }
</script>
